MonthDate   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
dl 0
loc 11
c 0
b 0
f 0
rs 10

2 Functions

Rating   Name   Duplication   Size   Complexity  
A getFirstDay 0 3 1
A getLastDay 0 4 1
1
import { lastDayOfMonth, format } from 'date-fns';
2
3
export class MonthDate {
4
  constructor(public readonly year: number, public readonly month: number) {}
5
6
  getFirstDay(): Date {
7
    return new Date(`${this.year}-${String(this.month).padStart(2, '0')}-01`);
8
  }
9
10
  getLastDay(): Date {
11
    const localDate = lastDayOfMonth(this.getFirstDay());
12
    return new Date(format(localDate, 'yyyy-MM-dd'));
13
  }
14
}
15